<%@page import="org.json.simple.JSONArray"%>
<%@page import="dao.StudyDao"%>
<%@page import="vo.StudyVo"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("utf-8");
	String value=request.getParameter("value");
	String state=request.getParameter("state");
	
	/* String value="2";
	String state="category_list"; */
	
	System.out.println(value);
	System.out.println(state);
	
	List<StudyVo> list=null;
	StudyDao sdao = StudyDao.getDao(); 
	
	if(value!=null){
		int no = Integer.parseInt(value);
		if(state.equals("category_list")){
			list=sdao.selectCategory(no);
		}else if(state.equals("title_list")){
			list=sdao.selectTitle(no);
		}else if(state.equals("subject_list")){
			list=sdao.selectSubject(no);
		} 
	}
	
	
	JSONArray jarr = new JSONArray();
	jarr.addAll(list);
	out.println(jarr.toString());
%>